﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace XSTDZ.ERP.Domain.Models
{
    /// <summary>
    /// 权限
    /// </summary>
   public partial class Permission
    {
       public Permission()
       {
          // this.Operations = new HashSet<Operation>();
           this.RolePermissions = new HashSet<RolePermission>();
           this.UserPermissions = new HashSet<UserPermission>();
           this.Permissions = new HashSet<Permission>();
       }
       /// <summary>
       /// 当OrgParentId为空时，自动添加OrgParentId为当前ID
       /// </summary>
       /// <param name="org"></param>
       /// <returns></returns>
       public Permission InitPermission(Permission permission)
       {

           if (Guid.Equals(permission.ParentID, Guid.Empty))
           {
               permission.ParentID = permission.Id;
               permission.Level = 1;
               permission.IsEnableEdit = true;
           }
           else
           {
               permission.Level = Convert.ToSByte(this.Level + 1);
           }
           return this;
       }

      
    }
}
